package com.bp.hearthealth.pulse.lnapps.bp_db.bp_heartrate

import androidx.room.TypeConverter
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import java.lang.reflect.Type


/**
 * @author: isnoam
 * @package_name: CommentTypeConverter.kt
 * @description：
 */
class BpHeartRateTypeConverter {
    var gson = Gson()

    @TypeConverter
    fun stringToObjectList(data: String?): List<BpHeartRateBean>? {
        if (data == null) {
            return emptyList<BpHeartRateBean>()
        }
        val listType: Type = object : TypeToken<MutableList<BpHeartRateBean>?>() {}.type
        return gson.fromJson<MutableList<BpHeartRateBean>>(data, listType)
    }

    @TypeConverter
    fun objectListToString(someObjects: MutableList<BpHeartRateBean?>): String? {
        return gson.toJson(someObjects)
    }
}